<template>
  <el-dialog title="推荐用户列表" :visible.sync="visible" width="50%" append-to-body>
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true">
      <el-form-item label="是否有效:" prop="isEffective">
        <el-select v-model="queryParams.isEffective" placeholder="请选择是否有效" size="mini">
          <el-option
            v-for="dict in dict.type.is_effective_member"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="邮箱:" prop="email" size="mini">
        <el-input
          v-model="queryParams.email"
          placeholder="请输入邮箱"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="昵称:" prop="nickname" size="mini">
        <el-input
          v-model="queryParams.nickname"
          placeholder="请输入昵称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <el-row>
      <el-table :data="userList" height="260px">
        <el-table-column label="邮箱" prop="email" :show-overflow-tooltip="true" />
        <el-table-column label="昵称" prop="nickname" :show-overflow-tooltip="true" />
        <el-table-column label="头像" prop="avatar">
          <template slot-scope="scope">
            <image-preview class="list-img" :src="scope.row.avatar"/>
          </template>
        </el-table-column>
        <el-table-column label="注册时间" align="center" prop="createTime">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.createTime) }}</span>
          </template>
        </el-table-column>
        <el-table-column label="是否有效用户" align="center" prop="isEffective">
          <template slot-scope="scope">
            <dict-tag :options="dict.type.is_effective_member" :value="scope.row.isEffective"/>
          </template>
        </el-table-column>
        <el-table-column label="交易情况" align="center" prop="status">
          <template slot-scope="scope">
            <span> 未交易 </span>
          </template>
        </el-table-column>
      </el-table>
      <pagination
        v-show="total>0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />
    </el-row>
  </el-dialog>
</template>
<script>
import { invitePageList } from "@/api/triones/member";

export default {
  name: "recommendMemberList",
  dicts: ['is_effective_member'],
  data() {
    return {
      visible: false,
      total: 0,
      userList: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        uid: undefined,
        isEffective: undefined,
        email: undefined,
        nickname: undefined
      }
    };
  },
  methods: {
    show(uid, isEffective) {
      this.queryParams.isEffective = isEffective;
      this.queryParams.uid = uid;
      this.getList();
      this.visible = true;
    },
    // 查询表数据
    getList() {
      invitePageList(this.queryParams).then(res => {
        this.userList = res.rows;
        this.total = res.total;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    }
  }
}
</script>

<style scoped lang="scss">

</style>
